import { defineStore } from 'pinia'
import { getUserInfoApi } from '../api/user'

export const useUserStore = defineStore('user', {
	state: () => {
		return {
			// 当前登录的用户信息
			userInfo: null
		}
	},
	actions: {
		async getUserInfoAction() {
			const res = await getUserInfoApi();
			if(res.code == 200) {
				// 将请求结果保存到state的userInfo中
				this.userInfo = res.data;
			}
		}
	}
})